using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace MaterialUI
{
	[ExecuteInEditMode]
	[AddComponentMenu("MaterialUI/Color Copier", 100)]
	public class ColorCopier : UIBehaviour
	{
		[SerializeField]
		private Graphic m_SourceGraphic;

		[SerializeField]
		private Graphic m_DestinationGraphic;

		private Color m_LastColor;

		public Graphic sourceGraphic
		{
			get
			{
				return m_SourceGraphic;
			}
			set
			{
				m_SourceGraphic = value;
				UpdateColor();
			}
		}

		public Graphic destinationGraphic
		{
			get
			{
				return m_DestinationGraphic;
			}
			set
			{
				m_DestinationGraphic = value;
				UpdateColor();
			}
		}

		private void LateUpdate()
		{
			UpdateColor();
		}

		public void UpdateColor()
		{
			if ((bool)sourceGraphic && (bool)destinationGraphic && sourceGraphic.color != m_LastColor)
			{
				destinationGraphic.color = sourceGraphic.color;
				m_LastColor = sourceGraphic.color;
			}
		}
	}
}
